const Base = require('./base.js');

module.exports = class extends Base {
    indexAction() {
        return this.display();
    }

    async AddRoleAction(){
        const params = this.post();
        let affRows = await this.model("sys_role").add(params);
        if(affRows != 0){
            return this.success("添加成功");
        }
    }

    async EditRoleAction(){
        let params = this.post()
        let affRows = await this.model("sys_role").update(params);
        if(affRows != 0){
            return this.success("更新成功");
        }else{
            return this.fail("更新失败")
        }
    }
    
    async GetUserListAction(){
        const params = this.post();
        const data = await this.model("sys_role").select();
        return this.success(data);
    }


    async DeleteRoleAction(){
        let params = this.post();
        let data = await this.model("sys_role").where({id: params.id}).delete();
        if(data != 0){
            return this.success("删除成功");
        }
    }
    async pageDataAction() {
        const param = this.post();
        const data = await this.model('sys_role').pageData(param);
        return this.success(data);
    };
};